#pragma once
#include <QWidget>
#include <QLineEdit>
#include <QGridLayout>
#include <QPushButton>
#include <QSignalMapper>

class DigitalKeyboard : public QWidget {
    Q_OBJECT
public:
    explicit DigitalKeyboard(QWidget *parent = nullptr);
    void attachTo(QLineEdit *target); // 关联目标输入框

signals:
    void inputCompleted(const QString &text);

private slots:
    void handleKeyPress(const QString &text);
    void handleBackspace();
    void handleClear();

private:
    QLineEdit *m_target{nullptr};
    QSignalMapper *m_mapper;

    void createLayout();
    void applyStyle();
};
